package com.example.b_308.myapplication.view.user.register.createdepartment;

import android.content.Intent;
import android.os.Bundle;
import android.support.annotation.Nullable;
import android.view.View;
import android.widget.EditText;
import android.widget.TextView;

import com.example.b_308.myapplication.R;
import com.example.b_308.myapplication.comment.utils.Global;
import com.example.b_308.myapplication.comment.utils.JsonUtils;
import com.example.b_308.myapplication.model.Department;
import com.example.b_308.myapplication.view.base.BaseActivity;

import java.util.List;

/**
 * Created by B-308 on 2017/12/4.
 */
public class UpdateDepartmentActivity extends BaseActivity {

    EditText et_create_department;
    TextView btn;
    Department department;

    @Override
    protected void onCreate(@Nullable Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_update_department);
        getTitleBar().setTitle(Global.getString(R.string.editorial_department));
        getTitleBar().setSetting(Global.getString(R.string.save));
        getTitleBar().getIv_setting().setVisibility(View.GONE);
        getTitleBar().getTv_return().setVisibility(View.GONE);

        et_create_department = findView(R.id.et_create_department);
        btn = findView(R.id.tv_setting);
        btn.setOnClickListener(new View.OnClickListener() {
            @Override
            public void onClick(View v) {
                Intent intent = new Intent();
                department = new Department();
                department.setName(et_create_department.getText().toString());
                if (null == department) {
                    fail("部门名称为空，不能保存！");
                }
                intent.putExtra(Department.TAG, JsonUtils.tToJson(department));
                setResult(2, intent);
                finish();
            }
        });
    }
}
